package com.spzx.order;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.BaseEntity;

/**
 * @author LOGIN
 * @title GenMP
 * @create 2025/7/17 15:42
 * @description
 */
public class GenMP {
    public static void main(String[] args) {

        String moduleName = "order";
        FastAutoGenerator.create("jdbc:mysql://192.168.174.100:3306/spzx-" + moduleName + "?characterEncoding=utf-8&useSSL=false", "root", "root")
                .globalConfig(builder -> builder
                        .author("Login")
                        .outputDir("D:/develop/JavaCode/IdCode/spzx/" + moduleName)
                        .dateType(DateType.ONLY_DATE)
                        //.disableOpenDir()         //启动后不打开文件夹
                )
                .packageConfig(builder -> builder
                        .parent("com.spzx."+ moduleName)  //todo 必须写
                        .entity("domain")
                        .mapper("mapper")
                        .xml("mapper." + moduleName)    //todo 必须写  其他的默认就是这样
                        .service("service")
                        .serviceImpl("service.impl")
                        .controller("controller")
                )
                .strategyConfig(builder -> builder
                        .addInclude(
                                "order_info",
                                "order_item")

                        .entityBuilder()
                        .enableLombok()
                        .superClass(BaseEntity.class)
                        .addSuperEntityColumns(
                                "id",
                                "create_by",
                                "create_time",
                                "update_by",
                                "update_time",
                                "remark",
                                "del_flag")
                        //.addIgnoreColumns
                        .enableFileOverride()    //是否覆盖之前生成的代码 开启是覆盖    针对entity 实体类层的  如上

                        .mapperBuilder()
                        .enableFileOverride()


                        .serviceBuilder()
                        //.formatServiceFileName("I%sService") //service接口的命名规则   todo .formatServiceFileName("%sService")我的习惯，前面不加I
                        .enableFileOverride()              //针对service层的 覆盖

                        .controllerBuilder()
                        .superClass(BaseController.class)
                        .enableRestStyle()                //开启rest风格
                        .enableFileOverride()             //针对controller层的 覆盖
                )
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
